Learn R Programming

outbreaker (version 1.1-6)

simple outbreak simulator: Simulation of pathogen genotypes during disease outbreaks

Description

The function simOutbreak implements simulations of disease outbreaks. The infectivity of cases is defined by a generation time distribution. The function as.igraph allows to convert simulated transmission trees into igraph objects.

Usage

simOutbreak(R0, infec.curve, n.hosts=200, duration=50, seq.length=1e4,
            mu.transi=1e-4, mu.transv=mu.transi/2,
            rate.import.case=0.01, diverg.import=10, group.freq=1,
            spatial=FALSE, disp=0.1, area.size=10, reach=1, plot=spatial)

## S3 method for class 'simOutbreak': print(x, \dots)

## S3 method for class 'simOutbreak': [(x, i, j, drop=FALSE)

## S3 method for class 'simOutbreak': labels(object, \dots)

## S3 method for class 'simOutbreak': as.igraph(x, edge.col="black", col.edge.by="dist", vertex.col="gold", edge.col.pal=NULL, annot=c("dist","n.gen"), sep="/", ...)

## S3 method for class 'simOutbreak': plot(x, y=NULL, edge.col="black", col.edge.by="dist", vertex.col="gold", edge.col.pal=NULL, annot=c("dist","n.gen"), sep="/", ...)

disperse(xy, disp=.1, area.size=10)

Arguments

R0
the basic reproduction number; to use several groups, provide a vector with several values.
infec.curve
a numeric vector describing the individual infectiousness at time t=0, 1, ...
n.hosts
the number of susceptible hosts at the begining of the outbreak
duration
the number of time steps for which simulation is run
seq.length
an integer indicating the length of the simulated haplotypes, in number of nucleotides.
mu.transi
the rate of transitions, in number of mutation per site and per time unit.
mu.transv
the rate of transversions, in number of mutation per site and per time unit.
rate.import.case
the rate at which cases are imported at each time step.
diverg.import
the number of time steps to the MRCA of all imported cases.
spatial
a logical indicating if a spatial model should be used.
disp
the magnitude of dispersal (standard deviation of a normal distribution).
area.size
the size of the square area to be used for spatial simulations.
reach
the mean of the exponential kernel used to determine new infections.
plot
a logical indicating whether an animated plot of the outbreak should be displayed; only available with the spatial model.
group.freq
the frequency of the different groups; to use several groups, provide a vector with several values.
x,object
simOutbreak objects.
i,j, drop
i is a vector used for subsetting the object. For instance, i=1:3 will retain only the first three haplotypes of the outbreak. j and drop are only provided for compatibility, but not used.
y
present for compatibility with the generic 'plot' method. Currently not used.
col
the color of the vertices of the plotted graph.
edge.col
the color of the edges of the plotted graph; overridden by col.edge.by.
col.edge.by
a character indicating the type of information to be used to color the edges; currently, the only valid value is "dist" (distances, in number of mutations). Other values are ignored.
vertex.col
the colors to be used for the vertices (i.e., cases).
edge.col.pal
the color palette to be used for the edges; if NULL, a grey scale is used, with darker shades representing larger values.
annot
a character indicating the information to be used to annotate the edges; currently accepted values are "dist" (genetic distances, in number of mutations), and "n.gen" (number of generations between cases).
sep
a character used to separate fields used to annotate the edges, whenever more than one type of information is used for annotation.
xy
spatial coordinates used as input for the dispersal process.
...
further arguments to be passed to other methods

Value

  • === simOutbreak class === simOutbreak objects are lists containing the following slots:
    • n: the number of cases in the outbreak
    • dna: DNA sequences in the DNAbin matrix format
    • dates: infection dates
    • dynam: a data.frame containing, for each time step (row), the number of susceptible, infected, or recovered in the population.
    • id: a vector of integers identifying the cases
    • ances: a vector of integers identifying infectors ('ancestor')
    • nmut: the number of mutations corresponding to each ancestry
    • ngen: the number of generations corresponding to each ancestry
    • call: the matched call

Examples

Run this code
dat <- list(n=0)

## simulate data with at least 30 cases
while(dat$n < 30){
   dat <- simOutbreak(R0 = 2, infec.curve = c(0, 1, 1, 1), n.hosts = 100)
}
dat

## plot first 30 cases
N <- dat$n
plot(dat[1:(min(N,30))], main="First 30 cases")
mtext(side=3, text="nb mutations / nb generations")

## plot a random subset (n=10) of the first cases
x <- dat[sample(1:min(N,30), 10, replace=FALSE)]
plot(x, main="Random sample of 10 of the first 30 cases")
mtext(side=3, text="nb mutations / nb generations")

## plot population dynamics
head(dat$dynam,15)
matplot(dat$dynam[1:max(dat$onset),],xlab="time",
   ylab="nb of individuals", pch=c("S","I","R"), type="b")


## spatial model
w <-  exp(-sqrt((1:40)))
x <- simOutbreak(2, w, spatial=TRUE,
                 duration=500, disp=0.1, reach=.2)

## spatial model, no dispersal
x <- simOutbreak(.5, w, spatial=TRUE,
                 duration=500, disp=0, reach=5)

Run the code above in your browser using DataLab